const cloud = require("@cloudbase/node-sdk");

const app = cloud.init({
    env: cloud.SYMBOL_CURRENT_ENV,
});

var db = app.database();
const $ = db.command.aggregate
const _ = db.command
const ZXGameCian = db.collection('ZX-Game-Cian')
const ZXGameHouse = db.collection('ZX-Game-House')

// 获取openId云函数入口函数
exports.main = async (event, context) => {
    const res = await db
        .collection('ZX-Game-Cian')
        .aggregate()
        .lookup({
            from: 'ZX-Game-House',
            localField: '_id',
            foreignField: 'cianId',
            as: 'children'
        })
        .project({
            cianId: 0
        })
        .end()
        return res
};